<!--<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>-->
<!--<%-->
<!--String path = request.getContextPath();-->
<!--String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";-->
<!--%>-->

<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <base href="<%=basePath%>">
    <meta charset="UTF-8">
    <title>添加公告</title>

    <meta name="pragma" content="no-cache">
    <meta name="cache-control" content="no-cache">
    <meta name="content-type" content="text/html;charset=UTF-8">
    <meta name="expires" content="0">
    <!--	<%@ include file="../../script.html" %>-->
    <link th:insert="~{views/script :: tiancai}"/>

</head>

<style type="text/css">
    .myselect {
        height: 30px;
        width: 80%;

    }
</style>

<body style="width:100%;max-width:600px;padding:10px 30px;">
<form id="form" method="post">
    <strong>基本信息</strong>

    <section class="info-section">

        <table id="tb">
            <tr>
                <td class="text-title"> 标题：</td>
                <td>
                    <input type="text" style="width:80%;" name="title" value="${announcementVO.title}"
                           class="easyui-textbox theme-textbox-radius">
                    <input type="hidden" name="announcementid" value="${announcementVO.announcementid }">
                    <input type="hidden" name="user" value="${announcementVO.user }">
                    <input type="hidden" name="updatetime" value="${announcementVO.updatetime }">
                    <input type="hidden" name="createtime" value="${announcementVO.createtime }">

                </td>
            </tr>
            <tr>
                <td class="text-title"> 颜色：</td>
                <td>
                    <input type="text" style="width:80%;" name="color" value="${announcementVO.color}"
                           class="easyui-textbox theme-textbox-radius">

                </td>
            </tr>
            <tr>
                <td class="text-title"> 排序编号：</td>
                <td>

                    <input type="text" style="width:80%;" name="orderid" value="${announcementVO.orderid }"
                           class="easyui-textbox theme-textbox-radius">
                </td>
            </tr>
            <tr>
                <td class="text-title"> 是否显示：</td>
                <td>
                    <input type="radio" name="isshow" checked value="${announcementVO.isshow}"/>是
                    <input type="radio" name="isshow" value="${announcementVO.isshow}"/>否
                </td>
            </tr>
            <tr>
                <td class="text-title"> 是否发布：</td>
                <td>
                    <input type="radio" name="status" checked value="${announcementVO.status}"/>是
                    <input type="radio" name="status" value="${announcementVO.status}"/>否
                </td>
            </tr>
            <tr>
                <td class="text-title">通知部门：</td>
                <td class="text-content">
                    <select class="myselect" name="departmentid">
                        <option value="-1">请选择部门</option>
                    </select>
                </td>

            </tr>
            <tr>
                <td class="text-title">内容</td>
                <td class="text-content">
                    <textarea name="content" rows="10" style="width:80%;">${announcementVO.content}</textarea>
                </td>
            </tr>


            <tr>
                <td colspan="2" style="text-align: center;margin-top: 10px;">
                    <a href="javascript:void(0);" id="saveBtn" class="easyui-linkbutton button-primary">保存</a>
                    <a href="javascript:void(0);" id="resetBtn" class="easyui-linkbutton button-danger">重置</a>
                </td>
            </tr>

        </table>
    </section>
</form>

<script type="text/javascript">
    $(function () {
        //重置按钮
        $("#resetBtn").on("click", function (event) {
            $("#form").form("reset");
        });

        //为保存按钮添加事件
        $("#saveBtn").on("click", function (event) {
            $("#form").form("submit", {
                url: "manage/announcement/Announcement_saveOrUpdate.do",
                onSumbit: function () {
                    //调用easyui中form对象的validate方法对表单中数据进行校验，该方法返回boolean值，如果为false会阻止表单提交
                    return $("#form").form("validate");
                },
                success: function (data) {
                    var obj = eval("(" + data + ")");
                    if (obj.success) {
                        $.messager.alert("提示", obj.message);
                        parent.closeTopWindow();
                    } else {
                        $.messager.alert("警告", obj.message);
                    }
                }
            });
        });

    });
    //给部门添加下拉框选项
    $(function () {
        $.post(
            "manage/position/Department_findAll.do",
            function (data) {
                if (data) {
                    var departmentId = "${announcementVO.departmentid}";
                    $.each(data.data, function (index, obj) {
                        var option = $("<option" + " " + "value=" + obj.departmentid + ">" + obj.name + "</option>");
                        if (departmentId && departmentId == obj.departmentid) {
                            option.attr("selected", true);
                        }
                        $("select[name='departmentid']").append(option);
                    })
                }
            }, "json"
        )
    });
</script>
</body>
</html>
				
